/*LICENSE_BEGIN
 * ******************************************************************
 * Copyright 2006 by the Dainamite Robocup-Team at the
 * DAI-Labor, TU-Berlin (www.dai-labor.de)
 * 
 * Members of Dainamite are:
 * Holger Endert
 * Robert Wetzker
 * Thomas Karbe
 * Axel Heßler
 * Philippe Bütter
 * Felix Brossmann
 * 
 * Licensed under the GNU GPL (General Public License) Free Software 
 * License, Version 2. You may use this file only in compliance with 
 * the License. You may obtain a copy of the License at:
 * 
 * http://www.fsf.org/licensing/licenses/gpl.txt
 * ******************************************************************
LICENSE_END*/
package robocup.component.actions;

/**
 * A say action, which is used by the player-agents to communicate. With these,
 * simple messages can be exchanged.
 */
public class SayAction extends Action {
	/**
	 * The message. Note, that only few characters are allowed (see therefore
	 * at NumberConverter.digits). The length of a message is limited to
	 * 10 chars per default.
	 */
	private String _message;

	/**
	 * Some messages require to be enclosed in qoutes, others not. The default 
	 * is <code>true</true>, which counts for all agents, except for the 
	 * trainer.
	 */
	private boolean quotesOn = true;

	/**
	 * Constructor - a say-action
	 * 
	 * @param message
	 *            the communicated message
	 */
	public SayAction(String message) {
		this._message = message;
		this._type = TYPE.SAY;
	}

	/**
	 * Constructor - a say-action
	 * 
	 * @param message
	 *            the communicated message
	 * @param true,
	 *            if the message should be enclosed in quotes
	 */
	public SayAction(String message, boolean quotesOn) {
		this(message);
		this.quotesOn = quotesOn;
	}

	/**
	 * Returns the actions string representation:
	 * @return 
	 * (say ["]&lt;message&gt;["])<br><br>
	 */
	@Override
	public String toString() {
		StringBuffer buf = new StringBuffer();
		buf.append("(say ");
		if (this.quotesOn)
			buf.append("\"");
		buf.append(this._message);
		if (this.quotesOn)
			buf.append("\"");
		buf.append(")");

		return buf.toString();
	}

	/**
	 * @return Returns the message.
	 */
	public String getMessage() {
		return this._message;
	}

	/**
	 * Sets a new message
	 * @param message - the new message.
	 */
	public void setMessage(String message) {
		this._message = message;
	}
}
